/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is Forte for Java, Community Edition. The Initial
* Developer of the Original Code is Sun Microsystems, Inc. Portions
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.search.types;
import java.awt.*;
import java.beans.*;
import javax.swing.*;
import org.openide.*;
import org.openidex.search.*;
import org.netbeans.modules.search.res.*;
/**
* Customizer of TextType beans.
*
* @author Petr Kuzel
* @version 1.0
*/
public class TextCustomizer extends javax.swing.JPanel implements Customizer {
private TextType peer;
/** Creates new form FullTextCustomizer */
public TextCustomizer() {
initComponents ();
setBorder (new javax.swing.border.TitledBorder(getBorderLabel()));
ButtonGroup group = new ButtonGroup();
group.add(substringRadioButton);
group.add(regexpRadioButton);
}
/** Allow derived customizers.
*/
protected String getBorderLabel() {
return null;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents () {//GEN-BEGIN:initComponents
substringRadioButton = new javax.swing.JRadioButton ();
substringTextField = new javax.swing.JTextField ();
regexpRadioButton = new javax.swing.JRadioButton ();
regexpTextField = new javax.swing.JTextField ();
setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints1;
substringRadioButton.setText (Res.text("LABEL_SUBSTRING"));
substringRadioButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
substringRadioButtonActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.insets = new java.awt.Insets (4, 12, 4, 4);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
add (substringRadioButton, gridBagConstraints1);
substringTextField.setPreferredSize (new java.awt.Dimension (100, substringTextField.getPreferredSize ().height));
substringTextField.addKeyListener (new java.awt.event.KeyAdapter () {
public void keyReleased (java.awt.event.KeyEvent evt) {
substringTextFieldKeyReleased (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets (4, 4, 4, 8);
gridBagConstraints1.weightx = 1.0;
add (substringTextField, gridBagConstraints1);
regexpRadioButton.setText (Res.text("LABEL_RE"));
regexpRadioButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
regexpRadioButtonActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.insets = new java.awt.Insets (4, 12, 4, 4);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
add (regexpRadioButton, gridBagConstraints1);
regexpTextField.setPreferredSize (new java.awt.Dimension (100, regexpTextField.getPreferredSize ().height));
regexpTextField.addKeyListener (new java.awt.event.KeyAdapter () {
public void keyReleased (java.awt.event.KeyEvent evt) {
regexpTextFieldKeyReleased (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets (4, 4, 4, 8);
gridBagConstraints1.weightx = 1.0;
add (regexpTextField, gridBagConstraints1);
}//GEN-END:initComponents
private void regexpRadioButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_regexpRadioButtonActionPerformed
String text = regexpTextField.getText();
try {
peer.setRe(text);
} catch (IllegalArgumentException ex) {
}
}//GEN-LAST:event_regexpRadioButtonActionPerformed
private void substringRadioButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_substringRadioButtonActionPerformed
peer.setMatchString(substringTextField.getText());
}//GEN-LAST:event_substringRadioButtonActionPerformed
private void substringTextFieldKeyReleased (java.awt.event.KeyEvent evt) {//GEN-FIRST:event_substringTextFieldKeyReleased
peer.setMatchString(substringTextField.getText());
substringRadioButton.setSelected(true);
}//GEN-LAST:event_substringTextFieldKeyReleased
private void regexpTextFieldKeyReleased (java.awt.event.KeyEvent evt) {//GEN-FIRST:event_regexpTextFieldKeyReleased
regexpRadioButton.setSelected(true);
String text = regexpTextField.getText();
try {
peer.setRe(text);
regexpTextField.setForeground(Color.black);
} catch (IllegalArgumentException ex) {
regexpTextField.setForeground(Color.red);
}
}//GEN-LAST:event_regexpTextFieldKeyReleased
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton substringRadioButton;
private javax.swing.JTextField substringTextField;
private javax.swing.JRadioButton regexpRadioButton;
private javax.swing.JTextField regexpTextField;
// End of variables declaration//GEN-END:variables
/** Initialize customizer with proper values.
*/
public void setObject(final Object obj) {
peer = (TextType) obj;
// set default coloring
regexpTextField.setForeground(Color.black);
substringTextField.setForeground(Color.black);
/* Display in customizer. */
substringTextField.setText(peer.getMatchString());
regexpTextField.setText(peer.getRe());
if ( ! peer.getRe().equals(peer.WILDCARD))
regexpRadioButton.setSelected(true);
if ( ! peer.getMatchString().equals(peer.WILDCARD))
substringRadioButton.setSelected(true);
}
public void addPropertyChangeListener(final java.beans.PropertyChangeListener p1) {
}
public void removePropertyChangeListener(final java.beans.PropertyChangeListener p1) {
}
}
/*
* Log
* 4 Gandalf-post-FCS1.2.1.0 3/9/00 Petr Kuzel I18N
* 3 Gandalf 1.2 1/13/00 Radko Najman I18N
* 2 Gandalf 1.1 1/5/00 Petr Kuzel Margins used. Help
* contexts.
* 1 Gandalf 1.0 12/23/99 Petr Kuzel
* $
*/